package co.edu.javeriana.aes.patrones.monopolio.cliente;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JInternalFrame;

/**
 *
 * @author gersua
 */
public class ViewHandler implements ActionListener {

    final private Dimension dimension = new Dimension(1500, 750);
    private JInternalFrame loginInternalFrame;
    private JInternalFrame showRoomInternalFrame;
    private JInternalFrame chatInternalFrame;
    private JInternalFrame waitPlayersInternalFrame;
    private JInternalFrame gamePanelInternalFrame;

    public Dimension getDimension() {
        return dimension;
    }

    public JInternalFrame getGamePanelInternalFrame() {
        return gamePanelInternalFrame;
    }

    public void setGamePanelInternalFrame(JInternalFrame gamePanelInternalFrame) {
        this.gamePanelInternalFrame = gamePanelInternalFrame;
    }

    public void setLoginInternalFrame(JInternalFrame loginInternalFrame) {
        this.loginInternalFrame = loginInternalFrame;
    }

    public void setShowRoomInternalFrame(JInternalFrame showRoomInternalFrame) {
        this.showRoomInternalFrame = showRoomInternalFrame;
    }

    public void setChatInternalFrame(JInternalFrame chatInternalFrame) {
        this.chatInternalFrame = chatInternalFrame;
    }

    public void setWaitPlayersInternalFrame(JInternalFrame waitPlayersInternalFrame) {
        this.waitPlayersInternalFrame = waitPlayersInternalFrame;
    }

    @Override
    public void actionPerformed(ActionEvent ae) {
        if (ae.getSource() instanceof JButton) {
            if (((JButton) ae.getSource()).getName().equals("btnLogIn")) {
                loginInternalFrame.dispose();
                showRoomInternalFrame.setVisible(true);
            } else if (((JButton) ae.getSource()).getName().equals("btnCreateRoom")
                    || ((JButton) ae.getSource()).getName().equals("btnJoinRoom")) {
                showRoomInternalFrame.dispose();
                waitPlayersInternalFrame.setVisible(true);
            } else if (((JButton) ae.getSource()).getName().equals("btnStartGame")) {
                waitPlayersInternalFrame.dispose();
                gamePanelInternalFrame.setVisible(true);
            }
        }
    }
}
